import enums from '@/views/workflow/utils/enum'

export const formConf = { // 表单默认设置
  formRef: 'elForm',
  formModel: 'formData',
  size: 'medium', // 元素大小
  labelPosition: 'right', // label对齐方式
  labelWidth: 100, // label宽度
  formRules: 'rules',
  gutter: 15,
  disabled: false,
  readonly: true,
  span: 24,
  formBtns: true
}

export const inputComponents = [
  {
    label: '单行输入框',
    tag: 'el-input',
    tagIcon: 'input',
    placeholder: '请输入',
    defaultValue: undefined,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    clearable: true,
    prepend: '',
    append: '',
    'prefix-icon': '',
    'suffix-icon': '',
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: true,
    visible: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  {
    label: '多行输入框',
    tag: 'el-input',
    tagIcon: 'textarea',
    type: 'textarea',
    placeholder: '请输入',
    defaultValue: undefined,
    span: 24,
    showLabel: true,
    labelWidth: null,
    autosize: {
      minRows: 4,
      maxRows: 4
    },
    style: { width: '100%' },
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  {
    label: '密码',
    tag: 'el-input',
    tagIcon: 'password',
    placeholder: '请输入',
    defaultValue: undefined,
    span: 24,
    'show-password': true,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    clearable: true,
    prepend: '',
    append: '',
    'prefix-icon': '',
    'suffix-icon': '',
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  {
    label: '计数器',
    tag: 'el-input-number',
    tagIcon: 'number',
    placeholder: '',
    defaultValue: undefined,
    span: 24,
    showLabel: true,
    labelWidth: null,
    min: undefined,
    max: undefined,
    step: undefined,
    unit: '',
    'step-strictly': false,
    precision: undefined,
    'controls-position': 'right',
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input-number',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  {
    label: '富文本',
    tag: 'quill-editor',
    tagIcon: 'editor',
    action: '/api/uploads/saveMoreUploads/',
    span: 24,
    showLabel: true,
    labelWidth: null,
    required: true,
    disabled: false,
    options: {
      debug: 'info',
      placeholder: '请输入',
      readOnly: false,
      enable: true,
      theme: 'snow'
    },
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  {
    label: '文本内容',
    tag: 'div',
    tagIcon: 'text',
    fontSize: '14px',
    fontColor: '#303133',
    span: 24,
    showLabel: true,
    labelWidth: null,
    align: 'left',
    content: '显示文字',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  }
]

export const selectComponents = [
  {
    label: '下拉选择',
    tag: 'el-select',
    tagIcon: 'select',
    placeholder: '请选择',
    defaultValue: undefined,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    clearable: true,
    disabled: false,
    required: true,
    filterable: false,
    multiple: false,
    options: [
      {
        id: 1,
        value: 1,
        label: '选项1'
      },
      {
        id: 2,
        value: 2,
        label: '选项2'
      },
    ],
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/select',
    valueType: '',
    valueData: '',
    valueDataColumn: [],
    optionValueType: '',
    optionValueData: '',
    optionValueDataColumn: []
  },
  /*
  {
    label: '级联选择',
    tag: 'el-cascader',
    tagIcon: 'cascader',
    placeholder: '请选择',
    defaultValue: [],
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    props: {
      props: {
        multiple: false
      }
    },
    'show-all-levels': true,
    disabled: false,
    clearable: true,
    filterable: false,
    required: true,
    options: [{
      id: 1,
      value: 1,
      label: '选项1',
      children: [{
        id: 2,
        value: 2,
        label: '选项1-1'
      }]
    }],
    dataType: 'dynamic',
    labelKey: 'label',
    valueKey: 'value',
    childrenKey: 'children',
    separator: '/',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/cascader',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  */
  {
    label: '单选框组',
    tag: 'el-radio-group',
    tagIcon: 'radio',
    defaultValue: undefined,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: {},
    optionType: 'default',
    border: false,
    size: 'medium',
    disabled: false,
    required: true,
    options: [{
      label: '选项一',
      value: 1
    }, {
      label: '选项二',
      value: 2
    }],
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/radio',
    valueType: '',
    valueData: '',
    valueDataColumn: [],
    optionValueType: '',
    optionValueData: '',
    optionValueDataColumn: []
  },
  {
    label: '多选框组',
    tag: 'el-checkbox-group',
    tagIcon: 'checkbox',
    defaultValue: [],
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: {},
    optionType: 'default',
    border: false,
    size: 'medium',
    disabled: false,
    required: true,
    options: [{
      label: '选项一',
      value: 1
    }, {
      label: '选项二',
      value: 2
    }],
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/checkbox',
    valueType: '',
    valueData: '',
    valueDataColumn: [],
    optionValueType: '',
    optionValueData: '',
    optionValueDataColumn: []
  },
  {
    label: '开关',
    tag: 'el-switch',
    tagIcon: 'switch',
    defaultValue: false,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: {},
    disabled: false,
    required: true,
    'active-text': '',
    'inactive-text': '',
    'active-color': null,
    'inactive-color': null,
    'active-value': true,
    'inactive-value': false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/switch',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  {
    label: '滑块',
    tag: 'el-slider',
    tagIcon: 'slider',
    defaultValue: null,
    span: 24,
    showLabel: true,
    labelWidth: null,
    disabled: false,
    required: true,
    min: 0,
    max: 100,
    step: 1,
    'show-stops': false,
    range: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/slider',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  {
    label: '时间选择',
    tag: 'el-time-picker',
    tagIcon: 'time',
    placeholder: '请选择',
    defaultValue: null,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    disabled: false,
    clearable: true,
    required: true,
    'picker-options': {
      selectableRange: '00:00:00-23:59:59'
    },
    format: 'HH:mm:ss',
    'value-format': 'HH:mm:ss',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/time-picker',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  /* // 暂不开放
  {
    label: '时间范围',
    tag: 'el-time-picker',
    tagIcon: 'time-range',
    defaultValue: null,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    disabled: false,
    clearable: true,
    required: true,
    'is-range': true,
    'range-separator': '至',
    'start-placeholder': '开始时间',
    'end-placeholder': '结束时间',
    format: 'HH:mm:ss',
    'value-format': 'HH:mm:ss',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/time-picker'
  },
  */
  {
    label: '日期选择',
    tag: 'el-date-picker',
    tagIcon: 'date',
    placeholder: '请选择',
    defaultValue: null,
    type: 'date',
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    disabled: false,
    clearable: true,
    required: true,
    format: 'yyyy-MM-dd',
    'value-format': 'yyyy-MM-dd',
    readonly: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/date-picker',
    valueType: '',
    valueData: '',
    valueDataColumn: []
  },
  /* // 暂不开放
  {
    label: '日期范围',
    tag: 'el-date-picker',
    tagIcon: 'date-range',
    defaultValue: null,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: { width: '100%' },
    type: 'daterange',
    'range-separator': '至',
    'start-placeholder': '开始日期',
    'end-placeholder': '结束日期',
    disabled: false,
    clearable: true,
    required: true,
    format: 'yyyy-MM-dd',
    'value-format': 'yyyy-MM-dd',
    readonly: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/date-picker'
  },
  */
  {
    label: '评分',
    tag: 'el-rate',
    tagIcon: 'rate',
    defaultValue: 0,
    span: 24,
    showLabel: true,
    labelWidth: null,
    style: {},
    max: 5,
    'allow-half': false,
    'show-text': false,
    'show-score': false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/rate'
  },
  {
    label: '颜色选择',
    tag: 'el-color-picker',
    tagIcon: 'color',
    defaultValue: null,
    showLabel: true,
    labelWidth: null,
    'show-alpha': false,
    'color-format': '',
    disabled: false,
    required: true,
    size: 'medium',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/color-picker'
  },
  {
    label: '文件上传',
    tag: 'el-upload',
    tagIcon: 'upload',
    action: '/',
    // action: 'https://jsonplaceholder.typicode.com/posts/',
    // action: 'http://192.168.255.4:8888/uploads/saveOnlyUploads/', // 文件上传接口
    // actionMulti: 'http://192.168.255.4:8888/uploads/saveMoreUploads/', // 多文件上传接口
    // action: '/api/uploads/saveMoreUploads/',
    defaultValue: null,
    showLabel: true,
    labelWidth: null,
    disabled: false,
    required: true,
    accept: '',
    name: 'file',
    'auto-upload': true,
    showTip: false,
    buttonText: '点击上传',
    fileSize: 2,
    sizeUnit: 'MB',
    'list-type': 'text',
    multiple: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/upload'
  }
]

export const layoutComponents = [
  {
    layout: 'rowFormItem',
    tagIcon: 'row',
    type: 'default',
    justify: 'start',
    align: 'top',
    label: '行容器',
    layoutTree: true,
    children: [],
    document: 'https://element.eleme.cn/#/zh-CN/component/layout'
  },
  {
    layout: 'textItem',
    label: '文本内容',
    tag: 'p',
    tagIcon: 'text',
    fontSize: '14px',
    fontColor: '#303133',
    align: 'right',
    content: '显示内容'
  },
  {
    layout: 'tabsItem',
    tagIcon: 'tabs',
    defaultValue: '1',
    bodyStyle: '',
    label: '标签页',
    type: 'card', // 风格类型，card/border-card，默认card
    tabPosition: 'top', // 选项卡所在位置，top/right/bottom/left，默认top
    tabs: [
      { label: '标签一', name: '1', content: '', children: [], layoutTree: true },
      { label: '标签二', name: '2', content: '', children: [], layoutTree: true }
    ],
    document: 'https://element.eleme.cn/#/zh-CN/component/tabs'
  },
  {
    layout: 'cardItem',
    tagIcon: 'card',
    header: '标题',
    bodyStyle: '',
    shadow: 'always',
    label: '卡片',
    layoutTree: true,
    children: [],
    document: 'https://element.eleme.cn/#/zh-CN/component/card'
  },
  {
    layout: 'tableItem',
    label: '表格',
    tag: 'el-table',
    tagIcon: 'table',
    height: '',
    maxHeight: '',
    stripe: false,
    border: true,
    size: 'medium',
    fit: true,
    showSummary: false,
    showHeader: true,
    highlightCurrentRow: true,
    currentRowKey: '',
    optionValueType: Object.keys(enums.VALUE_TYPE)[6],
    optionValueData: '',
    optionValueDataColumn: [],
    valueType: Object.keys(enums.VALUE_TYPE)[6],
    valueData: '',
    editable: true, // 是否可编辑
    columns: [{
      type: 'index',
      columnKey: '',
      label: '序号',
      prop: '',
      width: '50',
      minWidth: '',
      visible: true,
      fixed: false,
      sortable: false,
      resizable: true,
      align: 'center',
      headerAlign: 'center',
      tag: '',
      showOverflowTooltip: false,
      component: {},
    },
    {
      type: '',
      columnKey: '',
      label: '',
      prop: '',
      width: '',
      minWidth: '',
      visible: true,
      fixed: false,
      sortable: false,
      resizable: true,
      align: 'center',
      headerAlign: 'center',
      tag: '',
      showOverflowTooltip: true,
      component: {}
    }],
    /** 辅助决策配置 */
    isDecision: false, // 是否开启辅助决策
    promptTemplate: '', // 主提示语
    condition: [], // 行提示语的条件
    /** 辅助决策配置 */
    
    /** 回溯配置 */
    backtrack: {
      isBacktrack: false, // 是否可回溯
      backtrackId: '', // 回溯配置的Id
      stepId: '', // 默认回溯的步骤Id
      backtrackParams: [], // 查看数据回溯传递的公共参数
    },
    /** 回溯配置 */
    document: 'https://element.eleme.cn/#/zh-CN/component/table'
  }
]
// 系统组件
export const sysComponents = 
{
  linkComponents: [ // 查看组件
    {
      sysType: 'link',
      label: '用户信息',
      tag: 'user-link',
      tagType: 'user-info',
      tagIcon: 'user',
      defaultValue: '',
      span: 24,
      showLabel: true,
      labelWidth: null,
      style: { width: '100%' },
      valueType: '',
      valueData: '',
      valueDataColumn: []
    },
    {
      sysType: 'link',
      label: '供应商信息',
      tag: 'supplier-link',
      tagType: 'supplier-info',
      tagIcon: 'supplier',
      defaultValue: '',
      span: 24,
      showLabel: true,
      labelWidth: null,
      style: { width: '100%' },
      valueType: '',
      valueData: '',
      valueDataColumn: []
    },
    {
      sysType: 'file',
      label: '文件查看',
      tag: 'user-file',
      tagIcon: 'file',
      accept: '',
      defaultValue: undefined,
      span: 24,
      showLabel: true,
      labelWidth: null
    },
  ],
  selectComponents: [ // 选择组件
    {
      sysType: 'select',
      label: '部门下拉树',
      tag: 'dept-select',
      tagType: 'dept-tree-select',
      tagIcon: 'tree',
      placeholder: '请选择',
      defaultValue: undefined,
      span: 24,
      showLabel: true,
      labelWidth: null,
      style: { width: '100%' },
      clearable: true,
      disabled: false,
      required: true,
      filterable: false,
      multiple: false,
      valueType: '',
      valueData: '',
      valueDataColumn: []
    }, 
    {
      sysType: 'select',
      label: '部门岗位',
      tag: 'dept-position-s',
      tagType: 'dept-pos-tree-select',
      tagIcon: 'tree',
      placeholder: '请选择',
      defaultValue: undefined,
      span: 24,
      showLabel: true,
      labelWidth: null,
      style: { width: '100%' },
      clearable: true,
      disabled: false,
      required: true,
      filterable: false,
      multiple: false,
      valueType: '',
      valueData: '',
      valueDataColumn: []
    },
    {
      sysType: 'select',
      label: '部门人员',
      tag: 'dept-user-s',
      tagType: 'dept-user-tree-select',
      tagIcon: 'tree',
      placeholder: '请选择',
      defaultValue: undefined,
      span: 24,
      showLabel: true,
      labelWidth: null,
      style: { width: '100%' },
      clearable: true,
      disabled: false,
      required: true,
      filterable: false,
      multiple: false,
      valueType: '',
      valueData: '',
      valueDataColumn: []
    },
    // {
    //   sysType: 'select',
    //   label: '部门岗位人员',
    //   tag: 'dept-position-user',
    //   tagType: 'dept-pos-user-dialog',
    //   tagIcon: 'tree',
    //   span: 24,
    //   showLabel: true,
    //   labelWidth: null,
    //   style: { width: '100%' },
    //   disabled: false,
    //   required: true,
    //   multiple: false,
    //   valueType: '',
    //   valueData: '',
    //   valueDataColumn: []
    // }
  ]
}

export const tableConf = {
  dataRef: 'eltable',
  tableModel: 'tableData',
  height: '',
  maxHeight: '',
  stripe: true,
  border: true,
  size: 'medium',
  fit: true,
  showSummary: false,
  showHeader: true,
  highlightCurrentRow: true,
  currentRowKey: ''
}

export const tableColumnConf = {
  type: '',
  columnKey: '',
  label: '',
  prop: '',
  width: '',
  minWidth: '',
  visible: true,
  fixed: '',
  sortable: false,
  resizable: true,
  align: 'center',
  headerAlign: 'center',
  tag: '',
  showOverflowTooltip: true,
  component: {}
}

// 组件rule的触发方式，无触发方式的组件不生成rule
export const trigger = {
  'el-input': 'blur',
  'el-input-number': 'blur',
  'quill-editor': 'blur',
  'el-select': 'change',
  'el-radio-group': 'change',
  'el-checkbox-group': 'change',
  'el-cascader': 'change',
  'el-time-picker': 'change',
  'el-date-picker': 'change',
  'el-rate': 'change',
  'dept-select': 'change',
  'dept-position-s': 'change',
  'dept-user-s': 'change',
  'dept-position-user': 'change',
  'el-upload': 'change',
  'el-color-picker': 'change',
}
